#include <string.h>
#include <iostream>
#include <erpc_client_setup.h>
#include <erpc_port.h>
#include "hello.h"


static void free_binary_t_struct(binary_t *data)
{
    if (data->data) {
        erpc_free(data->data);
    }
}

int main(int argc, char *argv[])
{
    erpc_transport_t transport = erpc_transport_tcp_init("127.0.0.1", 5555, false);
    erpc_mbf_t message_buffer_factory = erpc_mbf_dynamic_init();
    erpc_client_init(transport, message_buffer_factory);
    char *msg = "hello erpc!";
    binary_t b = {(uint8_t *)msg, (uint32_t)strlen(msg)};
    binary_t *resp = sayHello(&b);
    std::cout << "respond: " << resp->data << std::endl;
    free_binary_t_struct(resp);

    erpc_transport_tcp_close();

    return 0;
}
